import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/index.vue'
import Type from '../views/type.vue'
import Filep from '../views/file.vue'
import Mine from '../views/mine.vue'
import Search from '../views/search.vue'
import Essay from '../views/essay.vue'
import NoPath from '../views/nopath.vue'
Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [
  {
    path: '/',
    name: 'index',
    component: Index
  },
  {
    path: '/type',
    name: 'type',
    component: Type
  },
  {
    path: '/file',
    name: 'file',
    component: FileP
  },
  {
    path: '/mine',
    name: 'mine',
    component: Mine
  },
  {
    path: '/search',
    name: 'search',
    component: Search
  },
  {
    path: '/essay',
    name: 'essay',
    component: Essay
  },
  {
    path: '*',
    name: '404',
    component: NoPath
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
